package com.huang.wangpan.utils;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

/**
 * @author: liminghui
 * @date: 2020/12/20 0:23
 * @version: 1.0
 * @description:
 */
public class CommonUtils {
    public static String loadToken(HttpServletRequest request) {
        Cookie[] cookies = request.getCookies();
        String token = null;
        if (cookies != null) {
            for (Cookie cookie : cookies) {
                String cookieName = cookie.getName();
                if ("token".equals(cookieName)) {
                    token = cookie.getValue();
                    break;
                }
            }
        }
        return token;

    }
}
